﻿using System;

namespace TK
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class | AttributeTargets.Struct)]
    public class CSType : Attribute
    {
        public readonly Type Type;
        public CSType(Type type) { this.Type = type; }
    }

    /// <summary> Don't touch this field/property while reading/writing </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public class CSIgnore : Attribute
    {        
    }

    /// <summary>
    /// Store field/property with specified name. Useful for migration from previous version with member name changes
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public class CSName : Attribute
    {
        public readonly string Name;
        public CSName(string name) { this.Name = name; }
    }

    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public class CSVersion : Attribute
    {
        public readonly int Version;
        public CSVersion(int version) { this.Version = version; }
    }

    /// <summary> Use backing field (if exists) for property get/set (for autoproperties for example). Faster than set/get with calling get/set.</summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class CSDirect : Attribute
    {
        public readonly bool Get;
        public readonly bool Set;
        public CSDirect(bool get = true, bool set = true) { Get = get; Set = set; }
    }

    /// <summary>
    /// Store enums with names or values.
    /// StoreAs.Name - use ToString for this enum and store as string. Parse back to enum while reading. Independent from enum member values, but more slow than StoreAs.Value
    /// StoreAs.Value - use underlying type for store (int as usual) and convert from int to enum while reading. Compact & fast.
    /// </summary>
    [AttributeUsage(AttributeTargets.Enum)]
    public class CSOption : Attribute
    {
        public readonly StoreAs As;
        public CSOption(StoreAs storeAs) { As = storeAs; }
    }

    public enum StoreAs {
        Value,
        Name
    }
}